<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
    <script src="../vue.js"></script>
    <script>
        let c=3;
        let object={
            a:1,
            b:2,
            get c(){
                console.log('访问c');
                return c;
            },
            set c(val){
                console.log('设置c');
                c=val;
            },
        };

        let object2={
            a:1,
            b:2,
        }
        object2.c=3;
        console.log(object2);

        let dd=100;
        Object.defineProperty(object2,'d',{
            //value:4,
            //writable:true,  //默认为false
            //configurable:true,  //默认为false
            enumerable:true,
            get:function(){
                console.log('get');
                return dd;
            },
            set:function(val){
                // console.log(val);
                dd=val;
                console.log('set');
            }
        })
        console.log(object2.d);
        object2.d=5; //只有在defineProperty里wriable为true时，d值才能修改
        //delete object2.d; //只有在defineProperty里configurable为true时，才能对d进行操作
        for (const key in object2) { //只有在defineProperty里enumerable为true时,才能遍历出来
            console.log(key);
        }

        let nu=Object.create(null);  //这样创建的是没有属性的
        nu.a=100;
        for (const key in nu) {
            console.log(key);
            console.log(nu[key]);
        }
    </script>
</body>
</html>